#include //////// SERVO AND LED GLOBAL VARIABLES ///////// Servo myservo; // create servo object to control a servo int pos = 0; // variable to store the servo position static int switchPin = PC2; //static int led_pin1 = 10; //static int led_pin2 = PD6; static int servo_pin = PD5; //int minutes = 60000; // = 1 minuit in milliseconds //int track_time(); // time tracking variable using the for_loop void setup() { // set the switch as an input: pinMode(switchPin, INPUT); // set all the other pins you're using as outputs: // pinMode(led_pin2, OUTPUT); pinMode(servo_pin, OUTPUT); myservo.attach(servo_pin); // attaches the servo on pin 9 to the servo object } void loop() { delay(1000); if (digitalRead(switchPin) == HIGH) // check if the pushbutton is pressed. If it is, the buttonState is HIGH: { /// Start Servo Control Program /// for (pos = 0; pos <= 178; pos += 1) { // goes from 0 degrees to 178 degrees // in steps of 1 degree myservo.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position } delay(1000; for (pos = 178; pos >= 0; pos -= 1) { // goes from 178 degrees to 0 degrees myservo.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position } /// End of Servo Control Program /// } }